/*
 * MessageInfo.hpp
 *
 *  Created on: Nov 2, 2013
 *      Author: vladimir
 */

#ifndef MESSAGEINFO_HPP_
#define MESSAGEINFO_HPP_

#include "constants.hpp"

#include <type_traits>
#include <typeinfo>
#include <cstring>

namespace vjipc
{

struct MessageHeader
{
	char id[ 64 ];
};

template< typename T >
struct MessageInfo
{
	MessageInfo();


	MessageHeader header;
	T data;
};

template< typename T >
MessageInfo<T>::MessageInfo() :
	header(),
	data()
{
	std::strncpy( header.id, typeid( T ).name(), sizeof( header.id ) );

	static_assert( sizeof( *this ) <= MAX_MESSAGE_SIZE, "exceeded allowed message size" );
	static_assert( std::is_pod< T >::value, "has to be POD" );
}

} /* namespace vjipc */

#endif /* MESSAGEINFO_HPP_ */
